﻿using Essensoft.Paylinks.Alipay.Client;
using Essensoft.Paylinks.Alipay.Payments.Model;
using Essensoft.Paylinks.Alipay.Payments.Request;

namespace Pay.Core.AliPayCore
{
    /// <summary>
    /// App支付
    /// </summary>
    /// <param name="client"></param>
    /// <param name="options"></param>
    public class AppPay(IAlipayClient client, AlipayClientOptions options)
    {
        public async Task<string> PayAsync(AlipayTradeAppPayBizModel model)
        {
            model = new AlipayTradeAppPayBizModel
            {
                OutTradeNo = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff"),
                TotalAmount = "0.01",
                Subject = "App支付测试",
                NotifyUrl = "https://www.domain.com/Alipay/Payments/Notify/TradeResult"
            };
            var request = new AlipayTradeAppPayRequest();
            request.SetBizModel(model);
            var response = await client.SdkExecuteAsync(request, options);
            return response;
        }
    }
}
